package com.appbee.gdata.picasa.client;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.appbee.core.client.modular.IModulRegistry;
import com.appbee.core.client.modular.impl.ActivityModul;
import com.appbee.gdata.picasa.client.activity.PicasaAlbumActivity;
import com.appbee.gdata.picasa.client.activity.PicasaPhotoActivity;
import com.appbee.gdata.picasa.client.activity.PicasaPhotosActivity;
import com.google.gwt.inject.client.AsyncProvider;

@Singleton
public class PicasaActivityModul extends ActivityModul
{
	private static final String PICASA_PHOTOS = "picasaPhotos";
	private final AsyncProvider<PicasaPhotosActivity> picasaPhotosActivityProvider;
	private final AsyncProvider<PicasaPhotoActivity> picasaPhotoActivityProvider;
	private String photosActivityId;
	private String potoActivityId;
	private final IModulRegistry registry;

	@Inject
	public PicasaActivityModul(	IModulRegistry registry,
								AsyncProvider<PicasaAlbumActivity> picasaAlbumActivityProvider,
								AsyncProvider<PicasaPhotosActivity> picasaPhotosActivityProvider,
								AsyncProvider<PicasaPhotoActivity> picasaPhotoActivityProvider)
	{
		this.registry = registry;
		setDefaultActivty(picasaAlbumActivityProvider);
		this.picasaPhotosActivityProvider = picasaPhotosActivityProvider;
		this.picasaPhotoActivityProvider = picasaPhotoActivityProvider;
	}

	public void register()
	{
		register("photosthumbnail", "photo");
	}

	public void register(String photosActivityId,
							String potoActivityId)
	{
		this.photosActivityId = photosActivityId;
		this.potoActivityId = potoActivityId;
		register(photosActivityId, picasaPhotosActivityProvider);
		register(	photosActivityId + "_" + potoActivityId,
					picasaPhotoActivityProvider);
		registry.register(PICASA_PHOTOS, this);
	}

	public String getAlbumActivityId()
	{
		return currentNavItem.getPath();
	}

	public String getPhotosActivityId()
	{
		return currentNavItem.getPath() + "_" + photosActivityId;
	}

	public String getPotoActivityId()
	{
		return getPhotosActivityId() + "_" + potoActivityId;
	}

	@Override
	public String getName()
	{
		return "Picasa photoviewer";
	}

	@Override
	public String getId()
	{
		return PICASA_PHOTOS;
	}


}
